package kr.saeildadim.androidexam_saeildamil.chapter17;

import java.io.File;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Toast;

public class Ch17_CallOther extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_other);
		
	}
	public void mOnClick(View v){
		Intent intent ;
		switch(v.getId()){
		case R.id.ch17_other_btn01:
			intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.nave.com"));
			startActivity(intent);
			break;
		case R.id.ch17_other_btn02:
			intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:010-8856-6119"));
			startActivity(intent);
			break;
		case R.id.ch17_other_btn03:
			String sdPtah =Environment.getExternalStorageDirectory().getAbsolutePath();
			File file = new File(sdPtah+"/yang.jpg");
			
			Uri uri = Uri.fromFile(file);
			
			intent = new Intent(Intent.ACTION_VIEW, uri);
			intent.setDataAndType(uri, "image/jpeg");
			
			startActivity(intent);
			
			Toast.makeText(this, sdPtah, Toast.LENGTH_LONG).show();
			break;
		case R.id.ch17_other_btn04:
			intent = new Intent(Intent.ACTION_MAIN);
		//	intent.setClassName("andexam.ver4_1", "andexam.ver4_1.AndExam");
			ComponentName componentName = new ComponentName("andexam.ver4_1", "andexam.ver4_1.AndExam");
			
			intent.setComponent(componentName);
			startActivity(intent);
			break;
		case R.id.ch17_other_btn05://
			intent = new  Intent(Intent.ACTION_MAIN);
			intent.setClassName("com.example.add", "com.example.add.Add");
			intent.putExtra("left", 3);
			intent.putExtra("right", 4);
			startActivity(intent);
			break;
		case R.id.ch17_other_btn06://명시적
			intent = new Intent("com.example.add.MUL");
			intent.putExtra("mLeft", 3);
			intent.putExtra("mRight", 4);
			startActivity(intent);
			break;
		}
	}
	
}
